﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;

namespace ggprot
{
    public class GGNotifyReply : GGHeader
    {
        private int uin;
        private int status;
        private int features;
        private int remoteIp;
        private short remotePort;
        private byte imageSize;
        private byte unknown;
        private int flags;
        private int descSize;
        private string description;

        public int Uin
        {
            get { return uin; }
            set { uin = value; }
        }

        public int Status
        {
            get { return status; }
            set { status = value; }
        }

        public int Features
        {
            get { return features; }
            set { features = value; }
        }

        public int RemoteIp
        {
            get { return remoteIp; }
            set { remoteIp = value; }
        }

        public short RemotePort
        {
            get { return remotePort; }
            set { remotePort = value; }
        }

        public byte ImageSize
        {
            get { return imageSize; }
            set { imageSize = value; }
        }

        public byte Unknown
        {
            get { return unknown; }
            set { unknown = value; }
        }

        public int Flags
        {
            get { return flags; }
            set { flags = value; }
        }

        public int DescSize
        {
            get { return descSize; }
            set { descSize = value; }
        }

        public string Description
        {
            get { return description; }
            set { description = value; }
        }

        public GGNotifyReply(GGHeader header)
        {
            this.Type = header.Type;
            this.Length = header.Length;
        }

        public override void Read(NetworkStream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            uin = reader.ReadInt32();
            status = reader.ReadInt32();
            features = reader.ReadInt32();
            remoteIp = reader.ReadInt32();
            remotePort = reader.ReadInt16();
            imageSize = reader.ReadByte();
            unknown = reader.ReadByte();
            flags = reader.ReadInt32();
            descSize = reader.ReadInt32();
            description = descSize > 0 ? string.Concat(reader.ReadChars(descSize)) : null;
        }
    }
}
